package com.ling.simul.vo;


//import com.ustb.pansteel.pump.constant.CommonConstant;
import com.ling.simul.constant.CommonConstant;
import lombok.Data;

/**
 * 公众返回结果实体类(json的格式)
 *
 * @author cc
 */
@Data
public class ResultData {

    private String msg; // 返回信息
    private Integer code; // 状态
    private Object data;
    private Integer total; // 数据总数

    public ResultData() {
    }

    public ResultData(String msg, Integer code, Object data) {
        this.msg = msg;
        this.data = data;
        this.code = code;
        this.total = 0;
    }

    public ResultData(String msg, Integer code, Object data, Integer total) {
        this.msg = msg;
        this.data = data;
        this.code = code;
        this.total = total;
    }

    /**
     * 分页查询对象
     *
     * @param total
     * @param data
     * @return
     */
    public static ResultData ResultDataSuccess(Object data, long total) {
        return new ResultData("访问数据接口成功", CommonConstant.SUCCESS_STATUS, data, Integer.parseInt(total + ""));
    }

    /**
     * 分页查询对象
     *
     * @param total
     * @param data
     * @return
     */
    public static ResultData ResultDataSuccess(Object data, Integer total) {
        return new ResultData("访问数据接口成功", CommonConstant.SUCCESS_STATUS, data, total);
    }

    /**
     * 访问成功
     *
     * @param data
     * @return
     */
    public static ResultData ResultDataSuccess(Object data) {
        return new ResultData("访问数据接口成功", CommonConstant.SUCCESS_STATUS, data);
    }

    /**
     * 自定义访问成功
     *
     * @param msg
     * @param data
     * @return
     */
    public static ResultData ResultDataSuccessSelf(String msg, Object data) {
        return new ResultData(msg, CommonConstant.SUCCESS_STATUS, data);
    }

    /**
     * 访问失败自定义
     *
     * @param msg
     * @param data
     * @return
     */
    public static ResultData ResultDataFaultSelf(String msg, Object data) {
        return new ResultData(msg, CommonConstant.FAULT_STATUS, data);
    }

    public static ResultData ResultDataFaultSelf(String msg, Integer code, Object data) {
        return new ResultData(msg, code, data);
    }

    /**
     * 访问失败固定
     *
     * @param msg
     * @param data
     * @return
     */
    public static ResultData ResultDataFaultGd(String msg, Object data) {
        return new ResultData("访问数据失败，失败信息为：" + msg, CommonConstant.FAULT_STATUS, data);
    }

}
